<?php

namespace app\api\model;

use think\Model;

class WpsGoods extends Model
{
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    // 表名
    protected $name = 'wps_goods';

    // 0 下架 1 上架
    public $stateForSpecific = [0, 1];

    /**
     *  更新数据
     */
    public function updateData($where, $up)
    {
        return $this->where($where)->update($up);
    }

    public static function insertData($data)
    {
        $model = new self();
        $model->data($data)->allowField(true)->save();
    }

    public function goods_sku()
    {
        $this->hasMany(WpsGoodsSku::class, 'c_id', 'c_id');
    }
}
